import { createBrowserRouter } from 'react-router'

export const route = createBrowserRouter([
  {
    path: '/',
    async lazy() {
      const { Home } = await import('@/pages')
      return {
        element: <Home />,
      }
    },
    children: [
      {
        async lazy() {
          const { Add } = await import('@/pages')
          return {
            element: <Add />,
          }
        },
        index: true,
      },
      {
        path: '/app/add/:id',
        async lazy() {
          const { Add } = await import('@/pages')
          return {
            element: <Add />,
          }
        },
      },
      {
        path: '/app/chat/:id',
        async lazy() {
          const { Chat } = await import('@/pages')
          return {
            element: <Chat />,
          }
        },
      },
    ],
  },
  {
    path: '/user/login',
    async lazy() {
      const { Login } = await import('@/pages')
      return {
        element: <Login />,
      }
    },
  },
  {
    path: '/user/register',
    async lazy() {
      const { Register } = await import('@/pages')
      return {
        element: <Register />,
      }
    },
  },
])
